package com.itheima.sc.service.pms;

import com.itheima.sc.autoconfig.template.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Service
public class AliyunService {

    @Autowired
    private OssTemplate ossTemplate;

    public String upload(MultipartFile photoFile) {
        String url = null;
        try {
            url = ossTemplate.uploadImage(photoFile.getOriginalFilename(), photoFile.getInputStream());
        } catch (IOException e) {
            throw new RuntimeException("图片上传失败");
        }
        return url;
    }
}
